<? session_start();
						
include_once ('core/conn.php');
						
$db = get_conn();
						
check_session();
						

if($_GET['id'] != ''){
							
	$sql = " select * from invoices where id_invoice=".$_GET['id']; 
	$result = mysql_query($sql);	
							
	if($result){
								
		$row = mysql_fetch_array($result);
		$id_invoice = $row['id_invoice'];
		$id_location = $row['id_location'];
		$id_it = $row['id_it'];
		$amount = $row['amount'];
		$due_date = $row['due_date'];
		$exp_date = $row['exp_date'];
		$description = $row['description'];
		$istatus = $row['istatus'];
							
	}else{
								
		error_handling($sql,mysql_error());
							
	}
						
}						
					
?>
					
					
<html>
					
<head>
<script src="tools/jq_dp/js/jquery-1.4.4.min.js" type="text/javascript"></script>
<script src="tools/jq_dp/js/jquery-ui-1.8.11.custom.min.js" type="text/javascript"></script>
<link href="css/demos.css" rel="stylesheet" type="text/css" />
<script src="js/misc.js" type="text/javascript"></script>					
<script>
					
<!--
						
	function checkdata(obj){
							
		if(obj.id_it.value ==''){
			alert('Debe seleccionar el tipo de cobro');
			obj.id_it.focus();
			return false;
		}
		
		if(obj.due_date.value ==''){
			alert('Debe seleccionar la fecha de cobro');
			obj.due_date.focus();
			return false;
		}
		
		if(obj.exp_date.value ==''){
			alert('Debe seleccionar la fecha de vencimiento');
			obj.exp_date.focus();
			return false;
		}		
		
		
					
		


	return true;
						
	}
	



	$(function() {
		$( "#due_date" ).datepicker();
		$( "#exp_date" ).datepicker();
		
	});



	function refresh_list(){
		alert("x");	
	}

-->
</script>					
</head>									
					
<body>														
				
				
<form name='invoices' method='post' action='/core/invoices.php' onsubmit='return checkdata(this)'>
  <table width='54%' border='0'>
    <tr>
      <td colspan="2" align='left' nowrap>Editando </td>
    </tr>
    <tr>
      <td align='left' nowrap>Fileal:</td>
      <td align='left'><?php echo get_fileal_number($id_location)?>
      <input type="hidden" name="id_location" id="id_location" value="<?php echo $id_location?>"></td>
    </tr>
    <tr>
      <td width="13%" align='left' nowrap>Tipo de Cobro:</td>
      <td align='left'>
        <?php
	  
	  $extraitems ="<option value=''>Seleccione</option>";
      echo dbcombo("id_it","name ","invoices_type","id_it",$id_it,"name",$javascript,$extraitems);
	  ?>
      <input type="hidden" name="id_invoice" id="id_invoice" value="<?php echo $id_invoice?>"></td>
    </tr>
    <tr>
      <td align='left' nowrap>Al cobro desde</td>
      <td align='left'><input name="due_date" type="text" id="due_date" value="<?php echo $due_date?>" size="11"></td>
    </tr>
    <tr>
      <td align='left' nowrap>Fecha Vencimiento</td>
      <td align='left'><input name="exp_date" type="text" id="exp_date" value="<?php echo $exp_date?>" size="11"></td>
    </tr>
    <tr>
      <td align='left' nowrap>Monto</td>
      <td align='left' nowrap><input name="amount"   style="text-align:right" onKeyUp="only_numbers(this)" type="text" id="amount" value="<?php echo $amount?>" size="11"></td>
    </tr>
    <tr>
      <td align='left' nowrap>Comentarios</td>
      <td align='left' nowrap><textarea name="description" id="description" cols="20" rows="5"><?php echo $description?></textarea></td>
    </tr>
    <tr>
      <td align='left' colspan="2" nowrap><input type="submit" name="Actualizar" id="Actualizar" value="Guardar Cambios">
			<input type='button' name='quick_add2' value='Cancelar' onClick='parent.$.modal().close();'  />

      </td>
    </tr>
  </table>
</form>
					
</body></html>
<?php

	function get_locations_checkboxlist($filter,$filter_checked){
		$cols =1;
		if($filter==''){
			$filter = 1;
		}else{
			$filter =" id_location = ".$filter;	
		}
		
		$sql ="select * from locations where $filter order by  number";
		$result = mysql_query($sql);
		if($result){
			while($row = mysql_fetch_array($result)){
				if($counter ==0){
					$data.="<tr>";
				}
				
				if($filter_checked !=''){
					$status = " checked ";
				}
				
				$main_contact = get_owner_name($row['id_location']);
				
				$data.="<td><input type='checkbox' name='id_location[]' value='".$row['id_location']."' id='r_".$row['id_location']."' ".$status." ><label for='r_".$row['id_location']."'>".$row['number']." - ".$main_contact."</label></td>";
				$counter++;
				if($counter ==$cols){
					$data.="</tr>";
					$counter =0;
				}
			}//while
			return "<table border='0' >".$data."</table>";
		}else{
			
			error_handling("get_options: ".$sql,mysql_error());
		}			
	}
?>